"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Member = void 0;
const types_1 = require("../utils/types");
class Member extends types_1.MemberInterface {
    constructor() {
        super(...arguments);
        this.endpoint = {};
        this.candidatesQueue = {};
    }
    static createMember(options) {
        const { userId, username, socketId } = options;
        return new Member({ userId, username, socketId });
    }
    setEndpoint(userId, endpoint) {
        this.endpoint[userId] = endpoint;
    }
    getEndpoint(userId) {
        return this.endpoint[userId];
    }
    removeEndpoint(userId) {
        this.endpoint[userId].release();
        delete this.endpoint[userId];
    }
    stop(userId) {
        if (this.endpoint[userId] && this.endpoint[userId].release) {
            this.removeEndpoint(userId);
        }
        if (this.pipeline && this.pipeline.release) {
            if (!userId || userId === this.userId) {
                this.pipeline.release();
                this.pipeline = undefined;
            }
        }
    }
}
exports.Member = Member;
